home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mkmf.prog / RCS / mkmf,v < prev    next >
Encoding:
Text File  |  1992-11-25  |  11.5 KB  |  667 lines

  1. head     1.16;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @# @;
  7.  
  8.  
  9. 1.16
  10. date     91.11.03.17.42.51;  author jhh;  state Exp;
  11. branches ;
  12. next     1.15;
  13.  
  14. 1.15
  15. date     91.11.03.15.36.29;  author jhh;  state Exp;
  16. branches ;
  17. next     1.14;
  18.  
  19. 1.14
  20. date     91.04.11.14.08.17;  author kupfer;  state Exp;
  21. branches ;
  22. next     1.13;
  23.  
  24. 1.13
  25. date     90.11.13.11.14.27;  author jhh;  state Exp;
  26. branches ;
  27. next     1.12;
  28.  
  29. 1.12
  30. date     90.10.10.13.01.27;  author jhh;  state Exp;
  31. branches ;
  32. next     1.11;
  33.  
  34. 1.11
  35. date     90.02.16.13.45.33;  author rab;  state Exp;
  36. branches ;
  37. next     1.10;
  38.  
  39. 1.10
  40. date     89.09.20.15.59.33;  author douglis;  state Exp;
  41. branches ;
  42. next     1.9;
  43.  
  44. 1.9
  45. date     89.08.26.12.10.25;  author douglis;  state Exp;
  46. branches ;
  47. next     1.8;
  48.  
  49. 1.8
  50. date     89.08.26.12.05.50;  author douglis;  state Exp;
  51. branches ;
  52. next     1.7;
  53.  
  54. 1.7
  55. date     89.08.17.11.13.53;  author douglis;  state Exp;
  56. branches ;
  57. next     1.6;
  58.  
  59. 1.6
  60. date     89.06.05.13.09.59;  author ouster;  state Exp;
  61. branches 1.6.1.1;
  62. next     1.5;
  63.  
  64. 1.5
  65. date     89.05.22.12.30.12;  author jhh;  state Exp;
  66. branches ;
  67. next     1.4;
  68.  
  69. 1.4
  70. date     89.05.21.20.43.42;  author jhh;  state Exp;
  71. branches ;
  72. next     1.3;
  73.  
  74. 1.3
  75. date     89.01.09.11.00.29;  author ouster;  state Exp;
  76. branches ;
  77. next     1.2;
  78.  
  79. 1.2
  80. date     89.01.09.10.43.46;  author ouster;  state Exp;
  81. branches ;
  82. next     1.1;
  83.  
  84. 1.1
  85. date     88.12.28.11.45.46;  author ouster;  state Exp;
  86. branches ;
  87. next     ;
  88.  
  89. 1.6.1.1
  90. date     89.08.18.11.14.33;  author douglis;  state Exp;
  91. branches ;
  92. next     ;
  93.  
  94.  
  95. desc
  96. @@
  97.  
  98.  
  99. 1.16
  100. log
  101. @didn't handle multiple -m options properly
  102. @
  103. text
  104. @#! /sprite/cmds/csh -f
  105. # Script to generate a Makefile, depending on the current directory.
  106. #
  107. # $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf,v 1.15 91/11/03 15:36:29 jhh Exp $
  108. #
  109. # The old way to prevent mkmf from working in a directory is
  110. # to have the comment
  111. #    # No mkmf
  112. # in Makefile.  This is being reversed to require a line of the form
  113. #    # Allow mkmf
  114. # before mkmf will run.
  115. #
  116.  
  117. #
  118. # First, make sure "." is not in the path!  Otherwise things like "sed"
  119. # can get screwed up when made in the corresponding sprite directory.
  120. #
  121. set path = (/sprite/cmds.$MACHINE /sprite/cmds)
  122. setenv MKMFDIR /sprite/lib/mkmf
  123. set dependall="pmake dependall"
  124. set depend="pmake depend"
  125. set userMap=()
  126. set sysMap=${MKMFDIR}/mkmf.map
  127. set defmachine=$MACHINE
  128. set distMap=${MKMFDIR}/mkmf.dist
  129. set machTypes=`grep -v "^#" /sprite/admin/machineTypes`
  130.  
  131. #
  132. # No global flags by default.
  133. #
  134. setenv MKMFFLAGS
  135.  
  136. #
  137. # If makeRCS is set, an RCS directory will be created should one not exist
  138. # If makeMd is set, a machine-dependent subdirectory will be created if
  139. # none exists already.
  140. #
  141. set makeRCS
  142. set makeMd
  143.  
  144. #
  145. # Process options.
  146. #
  147. set i=1
  148. set makefile=Makefile
  149. set machinesToDo
  150. set noglob
  151. set usage = 'Usage: mkmf [-x] [-f file] [-mtm | -m tm]'
  152. unset noglob
  153.  
  154.  
  155. while ( $i <= $#argv )
  156.     switch( "$argv[$i]" )
  157. #
  158. # Handle echoing
  159. #
  160.         case "-x" 
  161.             set echo
  162.             setenv MKMFFLAGS "$MKMFFLAGS -x"
  163.             shift
  164.             @@ i--
  165.             breaksw
  166. #
  167. # Figure out alternate makefile if -f given
  168. #
  169.         case "-f" :
  170.             if ($i != $#argv) then
  171.                 shift
  172.                 set makefile=$argv[$i]
  173.                 shift
  174.                 @@ i--
  175.             endif
  176.             breaksw
  177. #
  178. # Build list of machine types to be done.
  179. #
  180.         case "-m*" :
  181.             set tmp = `echo "$argv[$i]" | sed "s/-m//"`
  182.             if ("$tmp" == '') then
  183.                 if ($i != $#argv) then
  184.                 shift
  185.                 set machinesToDo = ($machinesToDo $argv[$i])
  186.                 unset dependall
  187.                 shift
  188.                 else
  189.                 echo "$usage"
  190.                 exit (1)
  191.                 endif
  192.             else
  193.                 set machinesToDo = ($machinesToDo $tmp)
  194.                 unset dependall
  195.                 shift
  196.             endif
  197.             @@ i--
  198.             breaksw
  199.         default :
  200.             echo "$usage"
  201.             exit(1)
  202.             breaksw
  203.     endsw
  204.     @@ i++
  205. end
  206.  
  207. #
  208. # If the caller has a .mkmf file in his/her home directory, source it
  209. # now;  this can be used to modify some of the controlling variables
  210. # above, like MKMFDIR and map.
  211. #
  212.  
  213. if (-e ~/.mkmf) then
  214.     source ~/.mkmf
  215. endif
  216.  
  217. #
  218. # Check for permission to do this:
  219. # egrep -s returns 0 if a match is found for the pattern.
  220. # If a "no mkmf" comment is found in the current makefile, we refuse to run.
  221. # If no "allow mkmf" comment is in the current makefile, we must ask permission
  222. # before proceeding (if permission given, save the old Makefile in a
  223. # backup location, just in case).
  224. #
  225. #
  226. if (-e $makefile) then
  227.     if ({ egrep -s '^#[     ]*[Nn]o mkmf' $makefile }) then
  228.         echo "Sorry, mkmf not allowed in this directory"
  229.         exit 1
  230.     else if (! { egrep -s '^#[     ]*[Aa]llow mkmf' \
  231.         $makefile }) then
  232.         echo "WARNING: no '# Allow mkmf' in existing $makefile"
  233.         echo -n "Ok to run mkmf? Enter 'y' if ok: "
  234.         set a="$<"
  235.         if ("$a" !~ [Yy]*) then
  236.             echo "mkmf aborted"
  237.             exit 1
  238.         endif
  239.         mv -f $makefile $makefile.~
  240.     endif
  241. endif
  242.  
  243. #
  244. # Determine what version of mkmf to run. Set $mkmf to contain that version name
  245. # Pass through mkmf.map looking for a line whose pattern matches the
  246. # current working directory and place the following fields into
  247. # 'ans'.
  248. #
  249.  
  250. set ans=()
  251. if ( "$userMap" != "") set ans=(`echo $cwd | awk -f $userMap`)
  252. if ( "$ans" == "")     set ans=(`echo $cwd | awk -f $sysMap`)
  253. set distdir=()
  254. if ( "$distMap" != "") set distdir=(`echo $cwd | nawk -f $distMap`)
  255. set mkmf=$ans[1]
  256. if ($ans[2] !~ [Yy]*) unset makeRCS
  257. if ($ans[3] !~ [Yy]*) then
  258.     unset depend
  259.     unset dependall
  260. endif
  261. if ($ans[4] !~ [Yy]*) unset makeMd
  262. setenv DISTDIR $distdir
  263. setenv SUBTYPE $ans[5]
  264. #
  265. # This is a kludge because the machine types "sun4c" and "ds5000" are
  266. # only visible in the kernel sources.
  267. #
  268. if ($ans[5] == "kernel") then
  269.     set machTypes=($machTypes "sun4c" "ds5000")
  270. endif
  271.  
  272. setenv MKMF ${MKMFDIR}/mkmf.$mkmf
  273. if (-x mkmf.local && ! -d mkmf.local) then
  274.     echo "Using mkmf.local"
  275.     set uselocal
  276. endif
  277.  
  278. #
  279. # Create RCS directory if it should be here but isn't
  280. #
  281. if ((! -e RCS) && $?makeRCS) then
  282.     echo "Making RCS directory."
  283.     mkdir RCS
  284. endif
  285.  
  286. #
  287. # Create ".md" directories (if they don't already exist) for those
  288. # machine types specified with the "-m" option.  Also check that the
  289. # machine types are valid.
  290. #
  291. if ("$machinesToDo" != "") then
  292.     set tmp=""
  293.     foreach i ($machinesToDo)
  294.     if (! -e $i.md) then
  295.         if (" $machTypes " =~ *\ $i\ *) then
  296.         echo "Making $i.md directory."
  297.         mkdir $i.md
  298.         chmod 775 $i.md
  299.         set tmp=($tmp $i)
  300.         else 
  301.         echo "$i isn't a valid machine type."
  302.         endif
  303.     else
  304.         set tmp=($tmp $i)
  305.     endif
  306.     end
  307.     if ("$tmp" == "") then
  308.     exit 1
  309.     else
  310.     set machinesToDo=($tmp)
  311.     endif
  312. endif
  313.  
  314. #
  315. # Locate machine-dependent subdirectories (*.md) and set the environment
  316. # variable MACHINES to hold the names of the machines that we are to run
  317. # mkmf for, and ALLMACHINES to the names of all possible machine
  318. # types (without the ".md"suffixes).  
  319. # If no machine-dependent subdirectories exist, create one
  320. # if that's permitted.
  321. #
  322. set nonomatch
  323. set mds=(*.md)
  324. unset nonomatch
  325. set machines
  326. set domachines
  327. if ("$mds" != "*.md") then
  328.     foreach i ($mds)
  329.         set machName =  $i:r
  330.         if ("$machinesToDo" == "" || \
  331.             " $machinesToDo " =~ *\ $machName\ *) then
  332.             set domachines = ($domachines $machName)
  333.         endif
  334.         set machines = ($machines $machName)
  335.     end
  336. else
  337.     if ( $?makeMd ) then
  338.         echo "Making $defmachine.md directory."
  339.         mkdir $defmachine.md
  340.         if ("$machinesToDo" == "" || \
  341.             " $machinesToDo " =~ *\ $defmachine\ *) then
  342.             set machines=($defmachine)
  343.             set domachines=($defmachine)
  344.         endif
  345.     endif
  346. endif
  347. setenv MACHINES "$machines"
  348. setenv DOMACHINES "$domachines"
  349.  
  350. #
  351. # Store the name of the makefile we're manipulating in the MAKEFILE
  352. # envariable and invoke the appropriate version of mkmf
  353. #
  354. setenv MAKEFILE $makefile
  355. if ($?uselocal) then
  356.     eval ./mkmf.local $MKMFFLAGS $*
  357. else
  358.     eval ${MKMFDIR}/mkmf.$mkmf $MKMFFLAGS $*
  359. endif
  360.  
  361. #
  362. # if a .sed file exists for the makefile, muck with it some more
  363. #
  364. if (-e $makefile.sed) then
  365.     echo "Modifying with $makefile.sed."
  366.     mv $makefile{,.$$~~}
  367.     sed -f $makefile.sed $makefile.$$~~ > $makefile
  368.     rm $makefile.$$~~
  369. endif
  370.  
  371. #
  372. # if a .ex file exists for the makefile, edit the makefile using the .ex file
  373. # as a command script
  374. #
  375. if (-e $makefile.ex) then
  376.     echo "Modifying with $makefile.ex."
  377.     ex - $makefile < $makefile.ex
  378. endif
  379.  
  380. #
  381. # Form dependencies for the makefile if required
  382. #
  383. if ($?dependall) then
  384.     eval $dependall
  385. else if ($?depend) then
  386.     foreach i ($domachines)
  387.         eval $depend TM=$i
  388.     end
  389. endif
  390.  
  391. exit 0
  392. @
  393.  
  394.  
  395. 1.15
  396. log
  397. @added ds5000
  398. @
  399. text
  400. @d4 1
  401. a4 1
  402. # $Header: /sprite/src/cmds/mkmf.prog/RCS/mkmf,v 1.14 91/04/11 14:08:17 kupfer Exp $
  403. d79 1
  404. a79 1
  405.             if ($tmp == '') then
  406. d188 1
  407. a188 1
  408. if ($machinesToDo != "") then
  409. d204 1
  410. a204 1
  411.     if ($tmp == "") then
  412. @
  413.  
  414.  
  415. 1.14
  416. log
  417. @Get rid of DEFTARGET: the default target type is now set by a pmake
  418. library file (at "make" time).
  419. @
  420. text
  421. @d4 1
  422. a4 1
  423. # $Header$
  424. d162 2
  425. a163 2
  426. # This is a kludge because the machine type "sun4c" is only visible in
  427. # the kernel sources.
  428. d166 1
  429. a166 1
  430.     set machTypes=($machTypes "sun4c")
  431. @
  432.  
  433.  
  434. 1.13
  435. log
  436. @allows -m with unknown machine type
  437. @
  438. text
  439. @d4 2
  440. a245 6
  441. if ( "$machines" =~ *\ *) then
  442. # multiple machines
  443.     setenv DEFTARGET '\$(MACHINE)'
  444. else
  445.     setenv DEFTARGET $machines
  446. endif
  447. @
  448.  
  449.  
  450. 1.12
  451. log
  452. @creates the .md directory if it doesn't exist
  453. @
  454. text
  455. @d189 2
  456. a190 2
  457.     if (" $machTypes " =~ *\ $i\ *) then
  458.         if (! -e $i.md) then
  459. d194 3
  460. d198 1
  461. a199 2
  462.     else
  463.         echo "$i isn't a valid machine type."
  464. @
  465.  
  466.  
  467. 1.11
  468. log
  469. @Changes for distribution.
  470. @
  471. text
  472. @d24 1
  473. d159 8
  474. d179 26
  475. @
  476.  
  477.  
  478. 1.10
  479. log
  480. @look for mkmf.local instead of mkmf
  481. @
  482. text
  483. @d23 1
  484. d147 2
  485. d156 1
  486. @
  487.  
  488.  
  489. 1.9
  490. log
  491. @reinstated DEFTARGET, which we use after all and had been checked in  
  492. under a branch by mistake.  and then added the defmachine fix again.
  493. @
  494. text
  495. @d155 2
  496. a156 2
  497. if (-x mkmf && ! -d mkmf) then
  498.     echo "Using copy of mkmf in $cwd"
  499. d216 1
  500. a216 1
  501.     eval ./mkmf $MKMFFLAGS $*
  502. @
  503.  
  504.  
  505. 1.8
  506. log
  507. @changed defmachine to $MACHINE.
  508. @
  509. text
  510. @d22 1
  511. a22 1
  512. set defmachine=${MACHINE}
  513. d203 6
  514. @
  515.  
  516.  
  517. 1.7
  518. log
  519. @removed DEFTARGET -- we use $MACHINE now.
  520. @
  521. text
  522. @d22 1
  523. a22 1
  524. set defmachine=sun3
  525. @
  526.  
  527.  
  528. 1.6
  529. log
  530. @Pick default machine from list of available machines.
  531. @
  532. text
  533. @a202 5
  534. if ( " $machines " =~ *\ $defmachine\ *) then
  535.     setenv DEFTARGET $defmachine
  536. else
  537.     setenv DEFTARGET $machines[1]
  538. endif
  539. @
  540.  
  541.  
  542. 1.6.1.1
  543. log
  544. @default TM to single directory if it exists, else to $MACHINE
  545. @
  546. text
  547. @d203 2
  548. a204 3
  549. if ( "$machines" =~ *\ *) then
  550. # multiple machines
  551.     setenv DEFTARGET '\$(MACHINE)'
  552. d206 1
  553. a206 1
  554.     setenv DEFTARGET $machines
  555. @
  556.  
  557.  
  558. 1.5
  559. log
  560. @can now do -mtm
  561. @
  562. text
  563. @a22 1
  564. setenv DEFTARGET $defmachine
  565. d203 5
  566. @
  567.  
  568.  
  569. 1.4
  570. log
  571. @added ability to do selected machine types
  572. @
  573. text
  574. @d44 3
  575. d48 1
  576. d50 1
  577. d54 6
  578. a59 6
  579.     if ("$argv[$i]" == "-x") then
  580.         set echo
  581.         setenv MKMFFLAGS "$MKMFFLAGS -x"
  582.         shift
  583.         @@ i--
  584.     endif
  585. d63 8
  586. a70 6
  587.     if (("$argv[$i]" == "-f") && ($i != $#argv)) then
  588.         shift
  589.         set makefile=$argv[$i]
  590.         shift
  591.         @@ i--
  592.     endif
  593. d74 24
  594. a97 8
  595.     if (("$argv[$i]" == "-m") && ($i != $#argv)) then
  596.         shift
  597.         set machinesToDo = ($machinesToDo $argv[$i])
  598.         shift
  599.         unset dependall
  600.         @@ i--
  601.     endif
  602.  
  603. @
  604.  
  605.  
  606. 1.3
  607. log
  608. @Slight change to last rev.
  609. @
  610. text
  611. @d18 2
  612. a19 1
  613. set depend="pmake dependall"
  614. d23 1
  615. d43 2
  616. d64 11
  617. d126 4
  618. a129 1
  619. if ($ans[3] !~ [Yy]*) unset depend
  620. d148 4
  621. a151 2
  622. # variable MACHINES to hold the names of the machines (without the ".md"
  623. # suffixes).  If no machine-dependent subdirectories exist, create one
  624. d158 1
  625. d161 6
  626. a166 1
  627.         set machines = ($machines $i:r)
  628. d172 5
  629. a176 1
  630.         set machines=($defmachine)
  631. d180 1
  632. d215 6
  633. a220 2
  634. if ($?depend) then
  635.     eval $depend
  636. @
  637.  
  638.  
  639. 1.2
  640. log
  641. @Don't keep backup Makefile unless the old Makefile wasn't
  642. automatically generated.
  643. @
  644. text
  645. @d95 1
  646. a95 1
  647.         mv -f $makefile $makefile.$$~
  648. @
  649.  
  650.  
  651. 1.1
  652. log
  653. @Initial revision
  654. @
  655. text
  656. @d78 2
  657. a79 1
  658. # before proceeding.
  659. d95 1
  660. d152 2
  661. a153 2
  662. # Backup old makefile, then store the name of the makefile we're manipulating
  663. # in the MAKEFILE envariable and invoke the appropriate version of mkmf
  664. a154 1
  665. if (-e $makefile) mv -f $makefile $makefile.$$~
  666. @
  667.